package com.briup.recognition.service.impl;

import com.briup.recognition.bean.Module;
import com.briup.recognition.bean.ModuleExample;
import com.briup.recognition.dao.ModuleMapper;
import com.briup.recognition.service.IModuleService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class ModuleServiceImpl implements IModuleService {
    @Resource
    private ModuleMapper moduleMapper;

    @Override
    public List<Module> query() {
        ModuleExample example=new ModuleExample();
        return  moduleMapper.selectByExample(example);
    }

    @Override
    public void saveOrUpdate(Module module) {
        if (module.getId()!=null){
            moduleMapper.updateByPrimaryKey(module);
        }else {
            moduleMapper.insert(module);
        }
    }

    @Override
    public void deleteById(long id) {
        moduleMapper.deleteByPrimaryKey(id);
    }
}
